Fix IPv6 handling in siteAdapter (bracketed hosts, proxy path, cache keys)#349
Open
RalfBarkow wants to merge 3 commits intofedwiki:mainfrom
Open
Fix IPv6 handling in siteAdapter (bracketed hosts, proxy path, cache keys)#349RalfBarkow wants to merge 3 commits intofedwiki:mainfrom
RalfBarkow wants to merge 3 commits intofedwiki:mainfrom
Conversation
journal fixups * bracket IPv6 + preserve port; canonicalize cache key * prefer http direct for loopback; proxy on https origins * replace protocol-relative/substring hacks with base reconstruction * fix arrow-function body, duplicate `let`, and closing parens * use template strings for realFlag consistently
* replace invalid arrow form (`=> const key ...`) with block body * add missing closing brace to balance function * removes leftover commented debug log * ensures valid syntax and consistent style in siteAdapter.js
paul90
reviewed
Sep 18, 2025
Member
paul90
left a comment
There was a problem hiding this comment.
From just an initial cursory glance.
These changes will also have an impact server side, and anywhere wiki names are used. A quick test shows it does not work with a server running in farm mode.
lib/siteAdapter.js
Outdated
|
|
||
| // IPv6/localhost-safe URL helpers ------------------------------------------- | ||
| const isLoopbackHost = h => | ||
| h === 'localhost' || h === '127.0.0.1' || h === '::1' || h === '[::1]'; |
Member
There was a problem hiding this comment.
This needs to cater for localhost subdomains.
Which is what if (site.split('.').at(-1).split(':')[0] === 'localhost') { is part of.
- Expand isLoopbackHost to properly recognize IPv6 addresses (::1 and [::1]) - Add support for 127/8 subnet and .localhost domains in loopback detection - Update test environment with proper DOM mocking using jsdom - Add comprehensive tests for favicon URL generation across different host types - Include fake-indexeddb and jsdom-global dev dependencies for testing - Fix asynchronous test timing issues with proper callback handling The IPv6 address handling now correctly identifies loopback addresses and generates appropriate HTTP URLs instead of scheme-relative URLs for local development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR should fix longstanding issues when running a wiki with IPv6 neighbors (e.g.
http://[::1]:4000) on Ubuntu and other systems with IPv6 enabled.Motivation
::1:4000hosts causedInvalid URLerrors in browsers andcurl./proxy/...without encoding."localhost", not::1or[::1].localForage(routes,withCredentials) were inconsistent:::1:3000vs[::1]:3000.getURL,getDirectURL, journal fixups) did brittle string surgery withsubstring(7).Changes
Add helpers:
normalizeSite,siteKey→ ensure canonical bracketed formhttpOriginFor,httpsOriginFor,proxyPathFor(encoded)isLoopbackSitedetection (supports::1,[::1], IPv4, localhost)Update
findAdapterQ:http://[::1]:port/...for loopbackReplace protocol-relative URLs (
//host/...) with explicit schemes.Replace string hacks with base reconstruction logic.
Canonicalize keys in
routeStoreandwithCredsStore.Clean up
findAdapter(proper arrow body).Use template strings for flag replacement consistently.
Testing
Local Test Farm setup with two wiki instances (ports 3000, 4000).
On Ubuntu with IPv6:
curl http://[::1]:4000/favicon.pngreturns 200curl http://localhost:3000/proxy/%5B::1%5D:4000/favicon.pngreturns 200Browser tests:
Verified flag replacement and journal/fork links resolve correctly.
Related
Checklist
findAdaptersyntax